﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MessageWorkflow.Dispatch
{
    /// <summary>
    /// Stops and returns on the first ex
    /// </summary>
    public class SingleErrorStrategy : IErrorStrategy
    {
        Exception _foundException;

        public bool OnError(Exception ex)
        {
            _foundException = ex;

            return false;
        }

        public void OnComplete()
        {
            if (_foundException != null)
            {
                throw _foundException;
            }
        }
    }
}
